var app = getApp()
const baseUrl = app.globalData.baseUrl;
Page({
  data: {
    navbar: ['全部', '待付款', '服务中', '完成'],
    currentTab: 0,
  },
  onLoad: function() {
    var that = this;
    var url = baseUrl+'/yq/order/list';
    var params = {};
    var success = res => {
      that.setData({
        orderList: res.info,
      })
      console.log("全部订单：", res)
    }
    var fail = res => {
      console.log("全部订单获取失败：", res)
    }
    app.request(url, params, success, fail);
  },
  navbarTap: function(e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
    // console.log(this.data.currentTab)
      var that = this;
    if (this.data.currentTab == 1) { //待付款
      var url = baseUrl + '/yq/order/topay';
    } else if (this.data.currentTab == 2){
      var url = baseUrl + '/yq/order/pending';
    } else if ((this.data.currentTab == 3)){
      var url = baseUrl + '/yq/order/complete';
    } else if ((this.data.currentTab == 0)) {
      var url = baseUrl + '/yq/order/list';
    }
      var params = {};
      var success = res => {
        that.setData({
          orderList: res.info,
        })
        console.log("订单信息获取成功：", res)
      }
      var fail = res => {
        console.log("订单获取失败：", res)
      }
      app.request(url, params, success, fail);
    }

})